<?php

namespace app\api\controller;

use app\api\model\CourseModel;
use think\Controller;

class Course extends Controller {
    function courselist() {
        $model = new CourseModel();
        $result = $model->courselist();
        return json($result);
    }

    function coursedetail() {
        $courseid = input('get.courseid');
        $model = new CourseModel();
        $result = $model->coursedetail($courseid);
        if ($result) {
            return json($result);
        } else {
            return json(['id' => 0]);
        }


    }

    function courseenroll() {
        $userid = input('get.userid');
        $courseid = input('get.courseid');


        $model = new CourseModel();
        $result = $model->courseenroll($userid, $courseid);
        return json($result);
    }

}